package org.github.choviwu.web.index;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by ChoviWu on 2018/05/08
 * Description:
 */
@Controller
public class LogoutController {


    @PostMapping(value = "/user/logout",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Object logout(HttpServletRequest request){
        request.getSession().invalidate();
        Subject subject = SecurityUtils.getSubject();
        subject.logout();
        return "index";
    }
}
